﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using HNG.Portal.BLL;
using HNG.Portal.DAL;
using HNG.Portal.DAL.EntityClasses;
using HNG.Portal.DAL.FactoryClasses;
using HNG.Portal.DAL.HelperClasses;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Data;
using HNG.LIB.Common;
/// <summary>
/// Summary description for FunctionExtend
/// </summary>
namespace HNG.LIB.Controls
{
    public class FunctionExtend
    {
        TblRoleManager _TblRoleManager = new TblRoleManager();
        
        public FunctionExtend()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public static void LoadPageSize(DropDownList _ddl)
        {
            _ddl.Items.Add(new ListItem("10 Bản ghi/trang", "10"));
            _ddl.Items.Add(new ListItem("20 Bản ghi/trang", "20"));
            _ddl.Items.Add(new ListItem("30 Bản ghi/trang", "30"));
            _ddl.Items.Add(new ListItem("50 Bản ghi/trang", "50"));
            _ddl.Items.Add(new ListItem("100 Bản ghi/trang", "100"));

            _ddl.SelectedIndex = 0;
        }

        public static void LoadTGBaoHanh(DropDownList _ddl)
        {
            _ddl.Items.Add(new ListItem("Ngày", "1"));
            _ddl.Items.Add(new ListItem("Tháng", "2"));
            _ddl.Items.Add(new ListItem("Năm", "3"));

            _ddl.SelectedIndex = 0;
        }

        public static void LoadCustomerStatus(DropDownList _ddl)
        {
            _ddl.Items.Add(new ListItem("Kích hoạt", enumCustomerStatus.Active.ToString()));
            _ddl.Items.Add(new ListItem("Chưa kích hoạt", enumCustomerStatus.NotActive.ToString()));
            _ddl.Items.Add(new ListItem("Khoá", enumCustomerStatus.Lock.ToString()));
            _ddl.SelectedIndex = 0;
        }
        public static void LoadGender(DropDownList _ddl)
        {
            _ddl.Items.Add(new ListItem("--", "0"));
            _ddl.Items.Add(new ListItem("Male", enumGender.Male.ToString()));
            _ddl.Items.Add(new ListItem("Female", enumGender.Female.ToString()));
            _ddl.SelectedIndex = 0;
        }

        public static void LoadBannerPoisition(DropDownList _ddl)
        {
            _ddl.Items.Add(new ListItem("--", "0"));
            _ddl.Items.Add(new ListItem("Trên", enumBannerPoisition.Top.ToString()));
            _ddl.Items.Add(new ListItem("Dưới", enumBannerPoisition.bottom.ToString()));
            _ddl.Items.Add(new ListItem("Trái", enumBannerPoisition.left.ToString()));
            _ddl.Items.Add(new ListItem("Phải", enumBannerPoisition.right.ToString()));
            _ddl.Items.Add(new ListItem("Giữa", enumBannerPoisition.main.ToString()));
            _ddl.SelectedIndex = 0;
        }

        public static void LoadViTri(DropDownList _ddl)
        {
            _ddl.Items.Clear();
            try
            {
                _ddl.Items.Add(new ListItem("--", "0"));
                _ddl.Items.Add(new ListItem("Trên", enumViTri.top.ToString()));
                _ddl.Items.Add(new ListItem("Dưới", enumViTri.bottom.ToString()));
                _ddl.Items.Add(new ListItem("Trái", enumViTri.left.ToString()));
                _ddl.Items.Add(new ListItem("Phải", enumViTri.right.ToString()));

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void LoadRloeGroup(DropDownList _ddl)
        {
            _ddl.Items.Clear();
            try
            {
                _ddl.Items.Add(new ListItem("Quản trị viên", enumRoleGroup.Administrator.ToString()));
                _ddl.Items.Add(new ListItem("Thành viên", enumRoleGroup.Member.ToString()));
                _ddl.Items.Add(new ListItem("Xem", enumRoleGroup.View.ToString()));

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void LoadPositionMenu(DropDownList _ddl)
        {
            _ddl.Items.Clear();
            try
            {
                _ddl.Items.Add(new ListItem("Tất cả", enumPositionMenu.All.ToString()));
                _ddl.Items.Add(new ListItem("Trên", enumPositionMenu.Top.ToString()));
                _ddl.Items.Add(new ListItem("Dưới", enumPositionMenu.bottom.ToString()));

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void LoadShowType(DropDownList _ddl)
        {
            _ddl.Items.Clear();
            try
            {
                _ddl.Items.Add(new ListItem("--", "0"));
                _ddl.Items.Add(new ListItem("Mặc định", enumShowType._default.ToString()));
                _ddl.Items.Add(new ListItem("Danh mục sản phẩm", enumShowType._DanhMucSanPham.ToString()));
                _ddl.Items.Add(new ListItem("Danh mục tin", enumShowType._DanhMucTin.ToString()));

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void LoadTarget(DropDownList _ddl)
        {
            _ddl.Items.Clear();
            try
            {
                _ddl.Items.Add(new ListItem("Trang trong", enumTarget._self.ToString()));
                _ddl.Items.Add(new ListItem("Trang ngoài", enumTarget._blank.ToString()));

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void LoadTypeSupport(DropDownList _ddl)
        {
            _ddl.Items.Clear();
            try
            {
                _ddl.Items.Add(new ListItem("Yahoo", enumTypeSupport.Yahoo.ToString()));
                _ddl.Items.Add(new ListItem("Skype", enumTypeSupport.Skype.ToString()));

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        public static void LoadShowTypeDefault(ListBox _ddl)
        {
            _ddl.Items.Clear();
            try
            {
                string LangID = HNG.LIB.Localization.LocalizationUtils.GetCurrentLanguage();
                _ddl.Items.Add(new ListItem("--", "0"));
                _ddl.Items.Add(new ListItem("Trang chủ", string.Format(HNG.LIB.Common.Connection.GetSetting("HomePage"), LangID)));
                _ddl.Items.Add(new ListItem("Giới thiệu", string.Format(HNG.LIB.Common.Connection.GetSetting("About"), LangID)));
                _ddl.Items.Add(new ListItem("Tin tức", string.Format(HNG.LIB.Common.Connection.GetSetting("NewsHome"), LangID)));
                _ddl.Items.Add(new ListItem("Sản phẩm", string.Format(HNG.LIB.Common.Connection.GetSetting("ProductListByCate"), LangID, 1, 1)));
                //_ddl.Items.Add(new ListItem("Download", string.Format(HNG.LIB.Common.Connection.GetSetting("Download"), LangID)));
                _ddl.Items.Add(new ListItem("Khách hàng", string.Format(HNG.LIB.Common.Connection.GetSetting("DoiTac"), LangID)));
                _ddl.Items.Add(new ListItem("Hỗ trợ", string.Format(HNG.LIB.Common.Connection.GetSetting("Support"), LangID)));
                _ddl.Items.Add(new ListItem("Tài nguyên", string.Format(HNG.LIB.Common.Connection.GetSetting("Resources"), LangID)));                
                _ddl.Items.Add(new ListItem("Liên hệ", string.Format(HNG.LIB.Common.Connection.GetSetting("Contact"), LangID)));

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static bool IsAdmin(int ThanhVienID)
        {
            bool chk = true;
            TblThanhVienEntity _TblThanhVienEntity = new TblThanhVienManager().SelectOne(ThanhVienID);
            if (_TblThanhVienEntity != null)
            {
                //neu khong la admin
                if (_TblThanhVienEntity.Role.Equals(enumRoleGroup.Administrator.ToString()) == false)
                {
                    chk = false;
                }
            }
            return chk;
        }
    }
}